//
//  XS_MyCourseItemCell.swift
//  XueDao
//
//  Created by 范东 on 2020/12/19.
//

import UIKit

class XS_MyCourseItemCell: UICollectionViewCell {

    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var recentLabel: UILabel!
    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var progressView: UIProgressView!
    @IBOutlet weak var progressLabel: UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        iconImageView.backgroundColor = .white
        iconImageView.layer.masksToBounds = true
        iconImageView.layer.cornerRadius = .scale*4
        iconImageView.contentMode = .scaleAspectFill
        
        titleLabel.font = .xsFont(name: .medium, .scale * 16)
        recentLabel.font = .xsFont(name: .medium, .scale * 12)
        contentLabel.font = .xsFont(.scale * 12)
        progressLabel.font = .xsFont(.scale * 12)
        
        progressView.clipsToBounds = true
        progressView.layer.cornerRadius = .scale*3.5
    }
    
    var _model : XS_CourseItemModel!
    public var model : XS_CourseItemModel!{
        set{
            _model = newValue
            //设置数据
            iconImageView.sd_setImage(with: URL.init(string: newValue.curriculumImgUrl), completed: nil)
            titleLabel.text = model.curriculumName
            contentLabel.text = "已学"+newValue.learnedDay+"天 | 倒计时"+newValue.lastDay+"天"
            if newValue.curriculumType != "offline" {
                progressView.progress = (Float(newValue.percentage) ?? 0.0)/100
                progressLabel.text = newValue.percentage+"%"
                progressView.isHidden = false
                progressLabel.isHidden = false
            }else{
                progressView.isHidden = true
                progressLabel.isHidden = true
            }
        }
        get{
            return _model
        }
    }

}
